package com.ruoyi.school.api.factory;

import com.ruoyi.school.api.RemoteSchoolTopService;
import com.ruoyi.school.api.model.TopVO;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * TOP服务降级处理
 * @author zhaoYuFei
 */
public class RemoteSchoolFallbackFactory implements FallbackFactory<RemoteSchoolTopService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteSchoolFallbackFactory.class);

    @Override
    public RemoteSchoolTopService create(Throwable cause) {
        log.error("TOP服务调用失败:{}", cause.getMessage());
        return new RemoteSchoolTopService() {
            @Override
            public List<TopVO> getSchoolTop() {
                log.error("学校TOP服务调用失败:{}", cause.getMessage());
                return new ArrayList<>();
            }

            @Override
            public List<TopVO> getSpecialityTop() {
                log.error("专业TOP服务调用失败:{}", cause.getMessage());
                return new ArrayList<>();
            }
        };
    }
}
